package com.zbkj.admin.controller.mszs;

import com.zbkj.common.model.mszs.MszsOrder;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.request.mszs.MszsOrderRequest;
import com.zbkj.common.request.mszs.MszsOrderSearchRequest;
import com.zbkj.common.request.mszs.MszsOrderUpdateRequest;
import com.zbkj.common.response.CommonResult;
import com.zbkj.common.response.mszs.MszsRoomOrderResponse;
import com.zbkj.service.service.mszs.MszsOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @description 民宿助手订单表-controller层
 * @author lijie
 * @date 2023-11-16
 */
@RestController
@RequestMapping(value = "api/admin/mszs/mszsOrder")
@Slf4j
@Api(tags = "民宿助手-订单管理")
public class MszsOrderController {

    @Autowired
    private MszsOrderService mszsOrderService;

    @PreAuthorize("hasAuthority('admin:mszs:mszsOrder:insert')")
    @ApiOperation(value="新增-酒店助手订单信息")
    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public CommonResult<Boolean> insert(@RequestBody @Validated MszsOrderRequest request){
        return CommonResult.success(mszsOrderService.insert(request));
    }

    @PreAuthorize("hasAuthority('admin:mszs:mszsOrder:delete')")
    @ApiOperation(value="刪除-根据id标识删除")
    @RequestMapping(value = "/delete", method = RequestMethod.GET)
    @ApiImplicitParam(name = "id", value = "主键id标识",required = true)
    public CommonResult<Boolean> delete(@RequestParam("id")int id){
        return CommonResult.success(mszsOrderService.delete(id));
    }

    @PreAuthorize("hasAuthority('admin:mszs:mszsOrder:update')")
    @ApiOperation(value="更新")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public CommonResult<Boolean> update(@RequestBody @Validated MszsOrderUpdateRequest request){
        return CommonResult.success(mszsOrderService.update(request));
    }

    @PreAuthorize("hasAuthority('admin:mszs:mszsOrder:load')")
    @ApiOperation(value="查询-根据主键id查询")
    @RequestMapping(value = "/load", method = RequestMethod.GET)
    @ApiImplicitParam(name = "id", value = "主键id标识",required = true)
    public CommonResult<MszsRoomOrderResponse> load(@RequestParam("id") int id){
        return CommonResult.success(mszsOrderService.load(id));
    }

    @PreAuthorize("hasAuthority('admin:mszs:mszsOrder:pageList')")
    @ApiOperation(value="查询-分页查询")
    @RequestMapping(value = "/pageList", method = RequestMethod.GET)
    public CommonResult<CommonPage<MszsOrder>> pageList(
            @Validated MszsOrderSearchRequest request,
            @Validated PageParamRequest pageParamRequest) {
        CommonPage<MszsOrder> mszsOrderPage = CommonPage.restPage(mszsOrderService.pageList(request,pageParamRequest));
        return CommonResult.success(mszsOrderPage);
    }

}